<?php

$title = array(
	'name'	=> 'activity_title',
	'id'	=> 'activity_title',
	'value' => (set_value('activity_title'))?set_value('activity_title'):(isset($activity[0]['activity_title'])?$activity[0]['activity_title']:'')
);
$title_label = '活動標題';


$date = array(
	'name'	=> 'activity_date',
	'id'	=> 'activity_date',
	'size'	=> '8',
	'value' => (set_value('activity_date'))?set_value('activity_date'):(isset($activity[0]['activity_date'])?$activity[0]['activity_date']:'')
);
$time = array(
	'name'	=> 'activity_time',
	'id'	=> 'activity_time',
	'size'	=> '8',
	'value' => (set_value('activity_time'))?set_value('activity_time'):(isset($activity[0]['activity_time'])?$activity[0]['activity_time']:'')
);
$date_label = '活動日期';

$duration = array(
	'name'	=> 'activity_duration',
	'id'	=> 'activity_duration',
	'size'	=> '5',
	'value' => (set_value('activity_duration'))?set_value('activity_duration'):(isset($activity[0]['activity_duration'])?$activity[0]['activity_duration']:'')
);
$duration_label = '活動時間';

$duration_kind = array(
	'minutes'	=>	'分鐘',
	'hours'	=>	'小時',
	'days'	=>	'天'
);

$location = array(
	'name'	=> 'activity_location',
	'id'	=> 'activity_location',
	'value' => (set_value('activity_location'))?set_value('activity_location'):(isset($activity[0]['activity_location'])?$activity[0]['activity_location']:'')
);
$location_label = '活動地點';


$category = array(
	'name'	=> 'activity_category',
	'id'	=> 'activity_category',
	'value' => (set_value('activity_category'))?set_value('activity_category'):(isset($activity[0]['activity_category'])?$activity[0]['activity_category']:'')
);
$category_label = '活動分類';

$min_p = array(
	'name'	=> 'activity_min_p',
	'id'	=> 'activity_min_p',
	'size'	=> '5',
	'value' => (set_value('activity_min_p'))?set_value('activity_min_p'):(isset($activity[0]['activity_min_p'])?$activity[0]['activity_min_p']:'')
);
$min_p_label = '最少';

$max_p = array(
	'name'	=> 'activity_max_p',
	'id'	=> 'activity_max_p',
	'size'	=> '5',
	'value' => (set_value('activity_max_p'))?set_value('activity_max_p'):(isset($activity[0]['activity_max_p'])?$activity[0]['activity_max_p']:'')
);
$max_p_label = '最多';

$price = array(
	'name'	=> 'activity_price',
	'id'	=> 'activity_price',
	'size'	=> '10',
	'value' => (set_value('activity_price'))?set_value('activity_price'):(isset($activity[0]['activity_price'])?$activity[0]['activity_price']:'')
);
$price_label = '活動價錢';


?>
<div>
	<?php
	$attributes = array('id'=>'save_activity');
	echo form_open('/activity_edit/modify/'.$activity_id.'/',$attributes); ?>
	<div>
		<div id="activity_property">
			<div><span><?php echo form_label($title_label,$title['id']); ?>：</span><?php echo form_input($title); ?><span style="color:red;"><?php echo form_error($title['name']); ?></span></div>
			<div><span><?php echo form_label($date_label,$date['id']); ?>：</span><?php echo form_input($date); ?><span style="color:red;"><?php echo form_error($date['name']); ?></span><?php echo form_input($time); ?><span style="color:red;"><?php echo form_error($time['name']); ?></span></div>
			<div><span><?php echo form_label($duration_label,$duration['id']); ?>：</span><?php echo form_input($duration); ?><?php echo form_dropdown('activity_duration_kind',$duration_kind,(set_value('activity_duration_kind'))?set_value('activity_duration_kind'):(isset($activity[0]['activity_duration_kind']))?$activity[0]['activity_duration_kind']:''); ?><span style="color:red;"><?php echo form_error($duration['name']); ?></span></div>
			<div><span><?php echo form_label($location_label,$location['id']); ?>：</span><?php echo form_input($location); ?><span style="color:red;"><?php echo form_error($location['name']); ?></span></div>
			<div><span><?php echo form_label($category_label,$category['id']); ?>：</span><?php echo form_input($category); ?><span style="color:red;"><?php echo form_error($category['name']); ?></span></div>
			<div><span>活動人數：</span><span><?php echo form_label($min_p_label,$min_p['id']); ?></span><?php echo form_input($min_p); ?><span style="color:red;"><?php echo form_error($min_p['name']); ?></span> - <span><?php echo form_label($max_p_label,$max_p['id']); ?></span><?php echo form_input($max_p); ?><span style="color:red;"><?php echo form_error($max_p['name']); ?></span></div>
			<div><span><?php echo form_label($price_label,$price['id']); ?>：</span><?php echo form_input($price); ?>元<span style="color:red;"><?php echo form_error('activity_price'); ?></span></div>
			<div><p>活動照片：</p><p><?php echo $image_uploader; ?></p></div>
		</div>
		
		<!-- Gets replaced with TinyMCE, remember HTML in a textarea should be encoded -->
		<div id="activity_desc">
			<p>活動敘述：<span style="color:red;"><?php echo form_error('desc'); ?></span></p>
			<textarea id="desc" name="desc" rows="30" cols="280" style="width: 60%">
				<?php
					echo (set_value('desc'))?set_value('desc'):(isset($activity[0]['desc'])?$activity[0]['desc']:'')
				?>
			</textarea>
		</div>

		<!-- Some integration calls -->
		<!--
		<a href="javascript:;" onclick="tinyMCE.get('elm1').show();return false;">[Show]</a>
		<a href="javascript:;" onclick="tinyMCE.get('elm1').hide();return false;">[Hide]</a>
		<a href="javascript:;" onclick="tinyMCE.get('elm1').execCommand('Bold');return false;">[Bold]</a>
		<a href="javascript:;" onclick="alert(tinyMCE.get('elm1').getContent());return false;">[Get contents]</a>
		<a href="javascript:;" onclick="alert(tinyMCE.get('elm1').selection.getContent());return false;">[Get selected HTML]</a>
		<a href="javascript:;" onclick="alert(tinyMCE.get('elm1').selection.getContent({format : 'text'}));return false;">[Get selected text]</a>
		<a href="javascript:;" onclick="alert(tinyMCE.get('elm1').selection.getNode().nodeName);return false;">[Get selected element]</a>
		<a href="javascript:;" onclick="tinyMCE.execCommand('mceInsertContent',false,'<b>Hello world!!</b>');return false;">[Insert HTML]</a>
		<a href="javascript:;" onclick="tinyMCE.execCommand('mceReplaceContent',false,'<b>{$selection}</b>');return false;">[Replace selection]</a>
		-->
		<br />
		
		<input type="submit" name="save" value="送出" onclick="unbindOnBeforeUnload()"/>
		<input type="button" name="saveasdraft" value="存為草稿" onclick="unbindOnBeforeUnload();saveAsDraft();"/>
	</div>
<?php echo form_close(); ?>
</div>